package com.kedacom.demo.spring.websocket.rpc.client;

import java.io.IOException;
import java.util.concurrent.ExecutionException;

import com.kedacom.demo.spring.websocket.rpc.PendingRequestHolder;
import com.kedacom.demo.spring.websocket.rpc.Response;
import com.kedacom.demo.spring.websocket.utils.JacksonUtils;

public class RPCWebSocketClientTest {

	public static void main(String[] args) throws IOException, InterruptedException, ExecutionException {
		String url = "ws://localhost:8080/demo-spring-websocket/websocket/rpc";

		PendingRequestHolder pendingRequestHolder = new PendingRequestHolder();
		RPCWebSocketClient rpcWebSocketClient = new RPCWebSocketClient(url, pendingRequestHolder);
		rpcWebSocketClient.init();

		Response response = rpcWebSocketClient.request("type1", "Oscar");
		System.out.println(JacksonUtils.toJsonString(response));
		response = rpcWebSocketClient.request("type1", "Hulk");
		System.out.println(JacksonUtils.toJsonString(response));

		rpcWebSocketClient.destory();
	}

}
